﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public class MyEventArgs : EventArgs
{
    private string m_TableName;

    public string TableName
    { get { return m_TableName; } }

    public MyEventArgs(string _tn)
    {
        m_TableName = _tn;
    }

}

public partial class WebUserControl : System.Web.UI.UserControl
{

    public event EventHandler Evt_Table_Click;

    private SavedReconciliation instanceRec;

    public SavedReconciliation Rec
    {
        get { return instanceRec; }
        set { instanceRec = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Rec != null)
        {
        this.lblRecId.Text = Rec.ID.ToString();
        this.lnkLeft.Text = Rec.LeftTable;
        this.lnkRight.Text = Rec.RightTable;
        this.lnkOutput.Text = Rec.OutPutTable;
        this.lblLastUsed.Text = Rec.LastRun.ToString();
        this.lnkRec.Text = (Rec.RecLink.ToString() == "-1") ? "None" : Rec.RecLink.ToString();
        }
    }
    protected void lnkLeft_Click(object sender, EventArgs e)
    {
        MyEventArgs x = new MyEventArgs(instanceRec.LeftTable);
        OnTableClicked(x); 
        
    }
    protected void lnkOutput_Click(object sender, EventArgs e)
    {
        MyEventArgs x = new MyEventArgs(instanceRec.OutPutTable);
        OnTableClicked(x);
    }
    protected void lnkRight_Click(object sender, EventArgs e)
    {
        MyEventArgs x = new MyEventArgs(instanceRec.RightTable);
        OnTableClicked(x);
    }
    protected void OnTableClicked(EventArgs e)
    {
        if (Evt_Table_Click != null)
        {
            Evt_Table_Click(this, e);
        }
    }
   
}